feat(fork): P0b — 场景 A worktree + WIP carry-over#252
Conversation
- 解析 /fork [--clean] [描述],--clean 透传给 forkSession - 删除 FORK_ALLOWED_USERS 白名单(devbot 已有 ALLOWED_USER_IDS,重复) - FORK_ENABLED 默认开启,改为 != 'false' 才关 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
P0a 之前对已 setup_workspace 的话题直接拒绝。P0b 实装:
- 在父 git 仓库上 'git worktree add -b <parent>-fork-<shortId>'
- 默认继承父 WIP: stash push -u → 子 stash apply → 父 stash pop
(git stash create 不支持 -u,只能走 push+pop 路径)
- /fork --clean 跳过 WIP 继承,子从纯 HEAD 起步
- 失败时按 JSONL → worktree → branch 顺序回滚
- 新增 reason 码 worktree_create_failed / stash_apply_failed
最危险分支:子 apply 成功但父 pop 失败 → 父 WIP 卡在 stash@{0},日志
CRITICAL 提示用户手动 'git stash pop' 恢复。
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5 个新 case 在 tmpdir 中 git init 真实仓库: - 默认: staged + unstaged + untracked 全继承,父工作树 status 不变 - --clean: 子是纯 HEAD,父 WIP 不传递 - 父无 WIP: stash push 不创建条目,子干净,不报错 - worktree_create_failed: 父非 git 仓库 → 干净回滚,无 JSONL/分支泄漏 - feishu 失败: worktree + branch + JSONL 都被清理 删除 scenario_a_not_supported_yet 旧 case(reason 已移除)。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
git stash create 不支持 -u(选项被当 message),无法捕获 untracked。 实装必须走 push --include-untracked → 子 apply → 父 pop 路径, 父工作树有亚秒级清空窗口(fork 同步,父 Claude idle,可接受)。 更新最危险分支说明。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 2m 10s —— View job Code Review —
|
- fork.ts: 更新 catch 注释,反映 push+pop 路径(原注释还说 stash create)
- fork.test.ts: afterEach 用 readdir+filter 真正清理 fork 子 worktree
(rmSync 不支持 glob,原 '${path}-fork-*' 是字面量被静默吞掉)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Claude finished @lishuceo's task in 1m 34s —— View job Code Review — ✅ Approved (2 previous issues fixed)
复核结果
没发现新问题
|
Summary
风险说明
父工作树有亚秒级"清空"窗口(`stash push` 之后、`pop` 之前)。/fork 是用户同步触发的,期间父话题 Claude idle 不写文件,可接受。
Test plan